<%--
  Created by IntelliJ IDEA.
  User: 13095
  Date: 2024/8/26
  Time: 11:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<c:set value="${pageContext.request.contextPath}" var="path"></c:set>
<script src="${path}/static/web/js/jquery-3.6.0.min.js"></script>
<link href="${path}/static/web/css/MsgStyle.css" rel="stylesheet" type="text/css" />

<html>
<head>
    <title>车位租赁</title>
</head>

<script>
    $(function (){
        $(".myform").submit(sub);
        $("#check").click(checkAll);
        }
    )

    function sub() {
        var year = $(this).parent().children().eq(8).children().eq(1).html();
        var money =$(this).parent().children().eq(2).val();
        if (year <= 0) {
            alert("一年起租");
            return false;
        }
        if (year*money>${money})
        {
            alert("余额不足");
            return  false;
        }
    }
    function  checkAll(){
        location.href="${path}/web/leaseParking";
    }

</script>
<body>
<script src="${path}/static/web/js/showParking.js" language="JavaScript" charset="UTF-8"></script>
<div class="div_container">
    <div class="searchDiv">
        <span>查询条件:</span>
        <form action="${path}/web/checkBeforeLease">
            <select name="condition">
                <option value='id'>车位ID</option>
                <option value='region'>所属区域</option>
                <option value='beizhu'>车位备注</option>
                <option value='parkingtype'>车位类型</option>
            </select>
            <span>查询值:</span>
            <input type="text" name="value">
            <input type="submit" value="查询">
            <input type="button" value="查询所有" id="check">
        </form>
    </div>
<table style=" margin:50px auto;" id="pageListTable">
     <thead>
              <tr>
                  <th>车位类型</th>
                  <th>租金</th>
                  <th>区域</th>
                  <th>备注</th>
                  <th>租赁时间</th>
                  <th>车辆</th>
                  <th>操作</th>
              </tr>
     </thead>
    <tbody id="pageListTableBody">
    <c:forEach items="${requestScope.parkingList}" var="park">
        <tr>
            <form class="myform" action="${path}/web/lease">
                <input type="hidden" value="${park.id}" name="id">
                <input type="hidden" value="${park.parkingType.money}"  name="money">
                <td>${park.parkingType.typeName}</td>
                <td>${park.parkingType.money} </td>
                <td>${park.region}</td>
                <td>${park.beizhu}</td>
                <td>  <input type="number" name="year" width="30">年</td>
                <td><select class="car" name="car_id"><c:forEach items="${requestScope.carList}" var="car"><option value="${car.id}">${car.license}</option></c:forEach></select>
                </td>

                <td><input type="submit" value="租赁"> </td>
            </form>
        </tr>
    </c:forEach>
    </tbody>
    <tfoot>
    <tr><td colspan="7">
        <div id="pages" style="float: right;margin-right: 20px;">
            <span id="spanFirst">首页</span>
            <span id="spanPre">上一页</span>
            <span id="spanNext">下一页</span>
            <span id="spanLast">尾页</span>
            第<strong id="spanPageNum"></strong>页/共
            <strong id="spanTotalPage"></strong>页
        </div>
    </td>
    </tr>
    </tfoot>
</table>
</div>

</body>
</html>
